home *** CD-ROM | disk | FTP | other *** search
- // MIDIClasses.h
- // A file devoted to developing an appropriate song data structure which eventually
- // can be translated to MIDI
-
- #ifndef __MUSICCLASS_
- #define __MUSICCLASS_
-
- #include <fstream.h>
- #define nil 0
-
- //enum VoiceStyle { CHORD
- long min(long a, long b);
-
- class Instrument {
- public:
- int pFlatness;
- int pAverage;
- int pContinuity;
- int pPeriod;
-
- int sFlatness;
- int sAverage;
- int sContinuity;
- int sPeriod;
-
- char InstNum;
-
-
- int index;
- };
-
- class Note {
- public:
- Note() {}
- Note(short pitch, long duration);
- void OutputToFile(ofstream& outFile);
- short pitch;
- long duration;
- char volume;
- };
-
- class Measure {
- public:
- Measure() {numNotes = 0;}
- void OutputToFile(ofstream& outFile, int measureNum);
- int AddNote(Note newNote); //returns numNotes
- int GetNumNotes();
- Note getStackedNote(int n);
- void setStackedNoteV(int n, char volume) {if (numNotes >= n) noteLine[numNotes - n].volume = volume;}
- void setStackedNoteP(int n, short pitch) {if (numNotes >= n) noteLine[numNotes - n].pitch = pitch;}
- private:
- int numNotes;
- Note noteLine[16];
- };
-
- class PitchLine {
- public:
- PitchLine() {}
- PitchLine(PitchLine* pitchLineNext, ifstream& fin);
- PitchLine*& getNext() {return next;}
- int getPitch(int forThis) {return pitchFunc[forThis];}
- private:
- int pitchFunc[64];
- PitchLine* next;
- };
-
- class SyncLine {
- public:
- SyncLine() {}
- SyncLine(SyncLine* next, PitchLine* corrLine, ifstream& fin);
- SyncLine*& getNext() {return next;}
- int getSync(int forThis) {return syncFunc[forThis];}
- private:
- int syncFunc[64];
- SyncLine* next;
- };
-
- class Unit {
- public:
- Unit() {pList = nil; sList = nil; nextUnit = nil;}
- Unit(ifstream& fin); //does all the work
- ~Unit() {} //does nothing interesting
-
- void OutputToFile(ofstream& outFile);
- Unit*& getNext() {return nextUnit;}
- long CountNumBytes();
- private:
- PitchLine* pList;
- SyncLine* sList;
- Measure mArray[12];
-
- Unit* nextUnit;
-
- void WriteMeasures(ifstream& fin);
- Note PickNote(int measurecount, PitchLine* pl, SyncLine* sl, int beat, char random);
- };
-
- class Song {
- public:
- Song ();
- Song(ifstream& fin);
- ~Song() {}
-
- void OutputToFile(ofstream& outFile);
- long CountNumBytes(); //the MTrk chunk needs to know its length
-
- private:
- Unit* headPointer;
- };
-
- #endif